#include "pagesettingsidenavi.h"
#include "ui_pagesettingsidenavi.h"

PageSettingSideNavi::PageSettingSideNavi(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PageSettingSideNavi)
{
    ui->setupUi(this);
    setAutoFillBackground(true);  //设置自动填充
    QPalette palette = BKGCLR;
    setPalette(palette);

    m_lNaviBtnName<<"牵引辅助\n复位"
                  <<"背光调节";
    InitBtns();
}

PageSettingSideNavi::~PageSettingSideNavi()
{
    delete ui;
}

void PageSettingSideNavi::InitBtns()
{
    uint8_t navibtncnt = m_lNaviBtnName.length();
    m_nNaviBtnLen = 110;
    m_nNaviBtnHeight = 60;
    m_nVSpace = 15;
    m_nStartx = (this->width()-m_nNaviBtnLen)/2;
    m_nStarty = (this->height()-navibtncnt*m_nNaviBtnHeight-(navibtncnt-1)*m_nVSpace)/2;

    for(uint i=0;i<navibtncnt;i++)
    {
        QPushButton *btn = new QPushButton(this);
        btn->setStyleSheet(SideNaviBtnStyle);
        btn->setGeometry(m_nStartx,m_nStarty+i*(m_nNaviBtnHeight+m_nVSpace),
                         m_nNaviBtnLen,m_nNaviBtnHeight);
        btn->setText(m_lNaviBtnName.at(i));
        btn->setCheckable(true);
        btn->setChecked(i==0);
        m_cNaviBtnGroup.addButton(btn,i+Page_Setting_ResetPCESIV);
    }
    connect(&m_cNaviBtnGroup,SIGNAL(buttonClicked(int)),this,SIGNAL(signal_show_setting_page(int)));
}

void PageSettingSideNavi::ResetBtnCheckStat()
{
    QAbstractButton* btnChecked = m_cNaviBtnGroup.checkedButton();
    btnChecked->setChecked(false);
    QAbstractButton* firstBtn = m_cNaviBtnGroup.button(Page_Setting_ResetPCESIV);
    firstBtn->setChecked(true);
}
